package com.ep.thirdPlatformProject.system.config.fadada;

import com.fasc.open.api.config.HttpConfig;
import com.fasc.open.api.stratey.DefaultJsonStrategy;
import com.fasc.open.api.v5_1.client.OpenApiClient;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Data
@Configuration
@ConfigurationProperties(prefix = "fadada", ignoreUnknownFields = true)
public class FaDaDaProperties {

    private String appId;

    private String appSecret;

    private String openCorpId;

    private String url;

    private String baseDir;

    @Bean
    public OpenApiClient openApiClient() {
        OpenApiClient openApiClient = new OpenApiClient(appId, appSecret, url);
        // 如果不设置超时时间 该设置可忽略
        HttpConfig httpConfig = new HttpConfig();
        httpConfig.setConnectTimeout(1000000);
        httpConfig.setReadTimeout(1000000);
        openApiClient.setHttpConfig(httpConfig);

        // Json序列化策率，默认使用Jackson，如果要使用其他如FastJson,Gson等实现JsonStrategy接口即可
        // 如果使用默认该设置可以忽略
        openApiClient.setJsonStrategy(new DefaultJsonStrategy());
        return openApiClient;

    }
}
